//求跳台阶方法
function func(n) {
    if (n <= 0) {
        return;
    }
    if (n == 1) {
        return 1;
    }
    if (n == 2) {
        return 2;
    }
    return func(n - 1) + func(n - 2); //递归查找上一个值
}
//跳台阶方法2
function jump2(n) {
    let target = 0, //返回的结果值
        number1 = 1, //前两个number值
        number2 = 2;

    if (n <= 0) {
        return 0;
    }
    if (n == 1) {
        return 1;
    }
    if (n == 2) {
        return 2;
    }
    //迭代求解
    for (let i = 3; i <= n; i++) {
        target = number1 + number2; //前两个的值和 = 后一个的值
        number1 = number2; //number1 number2往前挪
        number2 = target;
    }
    return target;
}
console.log(func(5), jump2(5));